﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using BLL;
namespace Stationery.UC
{
    public partial class UC_Category_Update_Parent : System.Web.UI.UserControl
    {
        MenuURL menuURL = new MenuURL();
        BLL_MenuURL bll_MenuURL = new BLL_MenuURL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["status"] == "edit")
            {
                Int64 intID = Convert.ToInt64(Request.Params["id_menu"].ToString());
                menuURL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL(intID))[0];
                ASPxTextBoxName.Text = menuURL.NAME;
                ASPxMemoDescription.Text = menuURL.DESCRIPTION;
            }

        }

        protected void ASPxButtonSave_Click(object sender, EventArgs e)
        {
            //luu
            string strStatus = "";
            Int32 intID;
            if (Request.Params["status"] != null)
            {
                strStatus = Request.Params["status"].ToString();
                if (Request.Params["status"] == "edit")
                {
                    intID = Convert.ToInt32(Request.Params["id_menu"].ToString());
                    menuURL.ID = intID;
                }
            }
            menuURL.ID_PARENT = 0;
            menuURL.NAME = ASPxTextBoxName.Text;
            menuURL.DESCRIPTION = ASPxMemoDescription.Text;
            menuURL.URL = "";
            menuURL.SEQUENCE = bll_MenuURL.Get_MenuURL_MaxColumn();
            menuURL.TYPE = MenuURL.column;
            if (bll_MenuURL.InsertUpdate_MenuURL(menuURL))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Thành công');location.href = 'Admin.aspx?id=category_parent';", true);
            }
        }

        protected void ASPxButtonCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect(UtilsURL.category_parent);
        }
    }
}